<extend name="common/layouts"/>


<block name="content">

    <div class="kt-portlet">
        <div class="kt-portlet__head">
            <div class="kt-portlet__head-label">
                <h3 class="kt-portlet__head-title">
                    课程打分
                </h3>
            </div>
        </div>
        <div class="kt-portlet__body">

            <!--begin::Section-->
            <div class="kt-section">
                <div class="kt-section__content">
                    <table class="table">
                        <thead>
                        <tr>
                            <th>#</th>
                            <th>学生名字</th>
                            <th>分数</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <foreach name="list" item="vo">
                            <tr>
                                <th>{$vo['id']}</th>
                                <th scope="row">{$vo['user']}</th>
                                <th scope="row">{$vo['score']}</th>
                                <td>
                                    <a class="btn btn-primary btn-sm" onclick="confirmScore({$vo['id']})">打分</a>
                                </td>
                            </tr>
                        </foreach>

                        </tbody>

                    </table>
                </div>
            </div>

            <div class="ck-paginate font-weight-bold kt-font-lg kt-font-regular">
                {$page}
            </div>
            <!--end::Section-->


        </div>

        <!--end::Form-->
    </div>
</block>

<block name="js">
    <script>
        var confirmScore = function (id) {
            var flag = window.prompt('请输入得分：');
            if (flag) {
                $.ajax({
                    url: '/home/class/scoreConfirm',
                    data: {
                        id: id,
                        score: flag
                    },
                    dataType: 'json',
                    type: 'post',
                    success: function (result) {
                        if (result.code == 0) {
                            toastr.success("打分成功");
                            setTimeout(function () {
                                window.location.reload();
                            }, 1500);
                        } else {
                            toastr.error(result.msg);
                            return;
                        }
                    }
                })
            }
        }
    </script>
</block>